﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Helper;
using System.ComponentModel;
namespace CoreData
{
    public class Student_Fee
    {
        [Description("ID")]
            public long ID{get;set;}
        [Description("StudentID")]
            public long StudentID{get;set;}
      //  [Description("Type")]
           // public int Type{get;set;}
        [Description("Đã đóng")]
            public long Money{get;set;}
        [Description("Status")]
            public int Status{get;set;}
        [Description("Ghi chú")]
            public string Description{get;set;}
        public long Order { get; set; }
            /// <summary>
            /// Tên hình thức đóng học phí
            /// </summary>
           [Description("Hình thức đóng")]
            public string TypeFeeNameExt { get; set; }
        [Description("Học viên")]
            public string StudentNameExt { get; set; }
        [Description("GVCN")]
            public string TeacherNameExt { get; set; }
        [Description("Mã học viên")]
            public string StudentCodeExt { get; set; }
        [Description("Lớp")]
            public string ClassNameExt { get; set; }
        [Description("Ngành")]
            public string BranchNameExt { get; set; }
        [Description("Khóa")]
            public string CourseNameExt { get; set; }
        [Description("Trạng thái")]
        public string StatusNameExt { get; set; }
        public int FeeToPayExt { get; set; } //so tien can phai dong
        public int TypeExt { get; set; }
        [Description("...")]
        public string ColorStatusExt { get; set; } // màu trạng thái hiển thị

        public int StudentInPutAmountExt { get; set; } //so luong nhap học
        public int StudentOutPutAmountExt { get; set; }//so luong hoc vien tot nghiep
        public int StudentOffAmountExt { get; set; }//so luong hoc vien nghi lun
        public int StudentSaveAmountExt { get; set; }// so lương học vien bao luu
        public int ClassTypeExt { get; set; }
        public int StudentStatusExt { get; set; }
        public string ClassNoteExt { get; set; }
        public int TotalMoneyExt { get; set; }
        public int ClassSizeExt { get; set; }
        public bool IsProcessExt { get; set; } // biên này dúng để bật tắt dòng nào đã xử lý rồi (ưng dụng cho report);
        public DateTime ClassStartDateExt { get; set; }
        public DateTime DateOfAdmissionExt { get; set; }
        public string PhoneExt { get; set; }
        public string AddressExt { get; set; }
        public string SexExt { get; set; }
        public DateTime DateOfBirthExt { get; set; }
        public int DiscountExt { get; set; }
        public DateTime RegisterDateExt { get; set; }
        public string TimeToStudeyExt { get; set; }
        public string ChannelExt { get; set; }
        public DateTime CreateDateVoucherExt { get; set; }
        public string TimeFeeExt { get; set; }
        [Description("Ngày bắt đầu đóng")]
        public DateTime StartPayDateExt { get; set; }//ngay bat dau dong hoc phi cua từng đợt
        public long Money1Ext { get; set; } //so tien dong lan 1
        public long Money2Ext { get; set; } // so tien dong lan 2
        public long Money3Ext { get; set; }//so tien dong lan 3
        public long Money4Ext { get; set; }//so tien dong lan 4
        public long Money5Ext { get; set; }//so tien dong lan 5
        public long Money6Ext { get; set; }//so tien dong lan 6
        
        public Student_Fee()
        {       
                            Description ="";   
        }
        
       static Student_Fee DynamicCast<T>(object row_data, object row_header) where T : Student_Fee
       {
           // row_data : DataRow
           // row_header : DataColumnCollection
           Student_Fee ret = new Student_Fee();
           DataRow dt = (DataRow)row_data;

           foreach (DataColumn column in (DataColumnCollection)row_header)
           {
               switch (column.ColumnName)
               {
                      case  "ID":
                        ret.ID = ConvertObject.ToLong(dt[column]);
                       break;
                      case  "StudentID":
                        ret.StudentID = ConvertObject.ToLong(dt[column]);
                       break;
                      case "Type":
                       {
                           ret.TypeExt = ConvertObject.ToInt(dt[column]);
                           if (ret.TypeExt == 1)
                           {
                               ret.TypeFeeNameExt = "Đóng một lần";
                           }
                           if (ret.TypeExt == 2)
                           {
                               ret.TypeFeeNameExt = "Đóng hai lần";
                           }
                           if (ret.TypeExt == 3)
                           {
                               ret.TypeFeeNameExt = "Đóng ba lần";
                           }
                           if (ret.TypeExt == 4)
                           {
                               ret.TypeFeeNameExt = "Đóng bốn lần";
                           }
                           if (ret.TypeExt == 6)
                           {
                               ret.TypeFeeNameExt = "Đóng sáu lần";
                           }
                       }
                       break;
                      case  "Money":
                        ret.Money = ConvertObject.ToLong(dt[column]);
                       break;
                      case "Status":
                       {
                           ret.Status = ConvertObject.ToInt(dt[column]);
                           if (ret.Status == 0)
                           {
                               ret.StatusNameExt = "Đóng đủ";
                           }
                           if(ret.Status==1) {
                               ret.StatusNameExt = "Đóng chưa đủ";
                           }if(ret.Status==2) {
                               ret.StatusNameExt = "Chưa đóng";
                           }
                       }
                       
                       break;
                      case  "Description":
                        ret.Description = ConvertObject.ToString(dt[column]);
                       break;
                      case "StudentCode":
                       ret.StudentCodeExt = ConvertObject.ToString(dt[column]);
                       break;
                      case "StudentName":
                       ret.StudentNameExt = ConvertObject.ToString(dt[column]);
                       break;
                      case "ClassName":
                       ret.ClassNameExt = ConvertObject.ToString(dt[column]);
                       break;
                      case "GVCN":
                       ret.TeacherNameExt = ConvertObject.ToString(dt[column]);
                       break;

                   case "CourseName":
                       ret.CourseNameExt = ConvertObject.ToString(dt[column]);
                       break;
                   case "BranchName":
                       ret.BranchNameExt = ConvertObject.ToString(dt[column]); 
                       break;
                   case "TotalFee":
                       ret.FeeToPayExt = ConvertObject.ToInt(dt[column]);
                       break;
                   case "Order":
                       ret.Order = ConvertObject.ToLong(dt[column]);
                       break;
                   case "ClassType":
                       ret.ClassTypeExt = ConvertObject.ToInt(dt[column]);
                       break;
                   case "StudentStatus":
                       {
                           ret.StudentStatusExt = ConvertObject.ToInt(dt[column]);
                          
                       }
                       break;
                   case "ClassNote":
                       ret.ClassNoteExt = ConvertObject.ToString(dt[column]);
                       break;
                   case "TotalMoney":
                       ret.TotalMoneyExt = ConvertObject.ToInt(dt[column]);
                       break;
                   case "SLBaoLUU":
                       ret.StudentSaveAmountExt = ConvertObject.ToInt(dt[column]);
                       break;
                   case "SLDangHoc":
                       ret.StudentInPutAmountExt = ConvertObject.ToInt(dt[column]);
                       break;
                   case "SLDATOTNGHIEP":
                       ret.StudentOutPutAmountExt = ConvertObject.ToInt(dt[column]);
                       break;
                   case "SLNGHILUON":
                       ret.StudentOffAmountExt = ConvertObject.ToInt(dt[column]);
                       break;
                   case "ClassSize":
                       ret.ClassSizeExt =ConvertObject.ToInt(dt[column]);
                       break;
                   case "DateOfAdmission":
                       ret.DateOfAdmissionExt = ConvertObject.ToDateTime(dt[column]);
                       break;
                   case "ClassStartDate":
                       ret.ClassStartDateExt = ConvertObject.ToDateTime(dt[column]);
                       break;

                   case "Address":
                       ret.AddressExt = ConvertObject.ToString(dt[column]);
                       break;
                   case "MoneyPay":
                       ret.Money = ConvertObject.ToInt(dt[column]);
                       break;
                   case "TimeFee": //ten lan dong hoc phi trong phieu thu hoc phi
                       ret.TimeFeeExt = ConvertObject.ToString(dt[column]);
                       break;
                   case "ChannelName":
                       ret.ChannelExt = ConvertObject.ToString(dt[column]);
                       break;
                   case "CreateDateVoucher":
                       ret.CreateDateVoucherExt = ConvertObject.ToDateTime(dt[column]);
                       break;
                   case "Phone":
                       ret.PhoneExt = ConvertObject.ToString(dt[column]);
                       break;
                   case "Discount":
                       ret.DiscountExt = ConvertObject.ToInt(dt[column]);
                       break;
                   case "Study_Time":
                       ret.TimeToStudeyExt = ConvertObject.ToString(dt[column]);
                       break;
                   case "DateOfBirth":
                       ret.DateOfBirthExt = ConvertObject.ToDateTime(dt[column]);
                       break;
                   case "Sex":
                         var sex = ConvertObject.ToBool(dt[column]);
                         if (sex == false)
                             ret.SexExt = "Nữ";
                         else
                             ret.SexExt = "Nam";
                       break;

                   case "TypeOfFee":
                       {
                           ret.TypeExt = ConvertObject.ToInt(dt[column]);
                           if (ret.TypeExt == 1)
                           {
                               ret.TypeFeeNameExt = "Đóng một lần";
                           }
                           if (ret.TypeExt == 2)
                           {
                               ret.TypeFeeNameExt = "Đóng hai lần";
                           }
                           if (ret.TypeExt == 3)
                           {
                               ret.TypeFeeNameExt = "Đóng ba lần";
                           }
                           if (ret.TypeExt == 4)
                           {
                               ret.TypeFeeNameExt = "Đóng bốn lần";
                           }
                           if (ret.TypeExt == 6)
                           {
                               ret.TypeFeeNameExt = "Đóng sáu lần";
                           }
                       }
                       break;
                   case "RegisterDate":
                       ret.RegisterDateExt = ConvertObject.ToDateTime(dt[column]);
                       break;
                  
                   default:
                       break;
               }
           }

           return ret;
       }
        
    }
}
